#include "dev/dacai/memory/gtc_mem.h"
#include "dev/dacai/memory/memory.h"
#include "dev/dacai/driver/driver.h"
#include "dev/mem.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"

#define WORKVALUEMIN 0
#define WORKVALUEMAX 9999

#define ALARMMSG "alarmmsg"
#define COMMUNICATESTOP "communicatestop"
struct t_companydesc
{
   uint8 icon;
   char name[50];
   char qrcode[128];
};
struct boot
{
    struct t_screendeal screendeal;
};
struct mainwaitgun
{
    struct t_screendeal screendeal;
};

struct maindouble
{
    struct t_screendeal screendeal;
};

struct wayselect
{
    struct t_screendeal screendeal;
};

struct waitpwd
{
    struct t_screendeal screendeal;
    char cardno[20];
    char password[20];
};

struct worktypeset
{
    struct t_screendeal screendeal;
    char worktype[10];
};

struct workvalueset
{
    struct t_screendeal screendeal;
    char  workvalue[10];
};

struct waitgun
{
   struct t_screendeal screendeal;

};

struct chargingac
{
   struct t_screendeal screendeal;

};

struct chargingdc
{
   struct t_screendeal screendeal;

};

struct charingcost
{
    struct t_screendeal screendeal;

};

struct settle
{
    struct t_screendeal screendeal;

};

struct alarm
{
   char screentype[20];
   struct t_screendeal screendeal;
};

struct managewaitpwd
{
   char password[20];
   struct t_screendeal screendeal;
};

struct manageselect
{
   struct t_screendeal screendeal;
};
struct sysvalueset
{
   int pageno;
   int pagetotal;
   int cnt;
   int maxcnt;

   uint8 driver[MANAGEMAX];
   uint8 flag;
   uint8 flagread;
   char type[30];
   char value[128];

   struct t_screendeal screendeal;
};
struct recordcheck
{
   char recordtype[30];
   int pageno;
   int pagetotal;
   struct t_screendeal screendeal;
};

struct debug
{
   struct t_screendeal screendeal;
};

struct communicate
{
   char type[20];
   struct t_screendeal screendeal;
};

struct t_gtcgun
{
   struct t_prodevyx yx;
   struct t_prodevyc yc;
   char gunqrcode[128];
};
struct t_screendata
{
    struct t_rtc time;
    struct t_proinitmsg proinitmsg;
    struct t_gtcgun gunmsg[TOTALGUN];//枪信息
    struct t_companydesc companydesc;
};
struct t_gtcscreen
{
    struct t_driver _driver;

    uint32 logo;
    uint32 companyname;
    uint32 netlogo;
    uint32 devnum;
    uint32 rtc;

    struct boot _boot;
    struct mainwaitgun _mainwaitgun;
    struct maindouble _maindouble;
    struct wayselect _wayselect;
    struct waitpwd _waitpwd;
    struct worktypeset _worktypeset;
    struct workvalueset _workvalueset;
    struct waitgun _waitgun;
    struct chargingac _chargingac;
    struct chargingdc _chargingdc;
    struct charingcost _charingcost;
    struct settle _settle;
    struct alarm _alarm;
    struct managewaitpwd  _managewaitpwd;
    struct manageselect _manageselect;
    struct sysvalueset _sysvalueset;
    struct recordcheck _recordcheck;
    struct debug _debug;
    struct communicate _communicate;
    uint32 screennow;//当前画面id
    uint32 gunselect;//当前枪号选择

    struct t_screendata screendata;//
};

enum {
    E_SCREEN_BOOT=	0,//	启动界面
    E_SCREEN_MAIN_WAITGUN,//	1	主界面(单枪)
    E_SCREEN_MAIN_DOUBLE,//	2	主界面(双枪)
    E_SCREEN_WAYSELECT,//	3	选择启动方式界面
    E_SCREEN_WAITPWD,//	4	等待输入密码界面
    E_SCREEN_WORKTYPE_SET,//	5	设置充电类型界面
    E_SCREEN_WORKVALUE_SET,//	6	设置充电参数界面
    E_SCREEN_WAITGUN,//	7	等待枪连接界面
    E_SCREEN_CHARGING_AC,//	8	充电中界面(交流)
    E_SCREEN_CHARGING_DC,//	9	充电中界面(直流)
    E_SCREEN_CHARGING_COST,//	10	充电中界面_费用信息
    E_SCREEN_SETTLE,//	11	结算界面
    E_SCREEN_ALARM,//	12	告警界面
    E_SCREEN_WAITPWD_MANAGE,//	13	等待输入密码界面(管理界面)
    E_SCREEN_MANAGE_SELECT,//	14	管理选择界面
    E_SCREEN_TYPEVALUE_SET,//	15	参数设置界面
    E_SCREEN_RECORD_CHECK,//	16	记录查看界面
    E_SCREEN_DEBUG,//	17	调试窗口界面
    E_SCREEN_COMMUNICATE,//	18	对框框
};
enum
{
    E_CONTROL_BASE = 0,
//控件	
    E_BUTTON_MANAGE	,//1	系统设置
    E_BUTTON_CANCEL	,//2	取消
    E_BUTTON_MAKESURE,//	3确定
    E_BUTTON_BYAUTO	,//4	自动充满
    E_BUTTON_BYTIME	,//5	按时间充
    E_BUTTON_BYPOWER,//	6	按度数充
    E_BUTTON_RETURN	,//7	返回
    E_BUTTON_SYSSET	,//8	参数设置
    E_BUTTON_RECORDCHECK,//	9	记录查看
    E_BUTTON_DEBUG	,//10	调试窗口
    E_BUTTON_ABOUTDEV,//	11	关于设备
    E_BUTTON_REBOOT,//	12	重启
    E_BUTTON_SAVE,//	13	保存
    E_BUTTON_FRONT,//	14	上一页
    E_BUTTON_NEXT,//	15	下一页
    E_BUTTON_STOP,//	16	停止充电

    E_BUTTON_BACKUP = E_CONTROL_BASE+20, //备份控件
    /*
    E_BUTTON_BACKUP+1,		//备份控件1
    E_BUTTON_BACKUP+2,		//备份控件2
    E_BUTTON_BACKUP+3,		//备份控件3
    E_BUTTON_BACKUP+4,		//备份控件4

    ...		...
    E_BUTTON_BACKUP+N		备份控件N
    */
    E_BUTTON_GUN = E_CONTROL_BASE+40,   //充电枪
    /*
    E_BUTTON_GUN +1,	 //充电枪1
    E_BUTTON_GUN +2,	 //充电枪2
    ...		...
    E_BUTTON_GUN +N		充电枪n
    */

//文本类
    E_TEXT_BASE = E_CONTROL_BASE + 80,//文本控件基准
    E_TEXT_COMPANYNAME,//	1	公司名称
    E_TEXT_VERUI,//	2	UI版本号
    E_TEXT_VERSOFTWARE,//	3	设备软件版本号
    E_TEXT_DEVNUM,//	4	桩编号
    E_TEXT_TITLE1,//	5	标题1
    E_TEXT_TITLE2,//	6	标题2
    E_TEXT_TELRPHONE,//	7	客服热线
    E_TEXT_WEB,//	8	官方网站
    E_TEXT_GUNNO,//	9	枪号
    E_TEXT_POINTMSG,//	10	提示信息
    E_TEXT_CARDNO,//	11	卡号
    E_TEXT_PASSWORD,//	12	密码
    E_TEXT_PARASET_TITLE,//13	设置充电参数_标题
    E_TEXT_PARASET_VALUE,//14	设置充电参数_值
    E_TEXT_PARASET_UNIT,//15	设置充电参数_单位
    E_TEXT_DEMAND_VOLTAGE,//16	需求电压
    E_TEXT_DEMAND_CURRENT,//17	需求电流
    E_TEXT_REMAINTIME,//18	剩余时间
    E_TEXT_SOC,//	19	SOC
    E_TEXT_POWERUSE,//	20	已充度数
    E_TEXT_STATE,//	21	状态
    E_TEXT_OUTPUT_VOLTAGE,//	22	输出电压
    E_TEXT_OUTPUT_CUEERNT,//	23	输出电流
    E_TEXT_TIME_USE,//	24	已充时间
    E_TEXT_TOTAL_POWER,//	25	总度数
    E_TEXT_TOTAL_TIME,//	26	总耗时
    E_TEXT_TOTAL_COST,//	27	总费用
    E_TEXT_RECORDTITLE,//	28	记录标题
    E_TEXT_PAGENO,//	29	页码序号
    E_TEXT_PAGETOTAL,//	30	页码总数
    E_TEXT_RECORDTYPE,//	31	记录类型

    E_TEXT_MANTYPE =E_TEXT_BASE+40,//管理界面键
    /*
    E_TEXT_MANTYPE+1,//		管理界面键1
    ...		...
    E_TEXT_MANTYPE+n		管理界面键n
    */
    E_TEXT_MANVALUE = E_TEXT_BASE+80,//管理界面值
    /*
    E_TEXT_MANVALUE+1	 	管理界面值1
    ...
    E_TEXT_MANVALUE+n
    */

//图标控件
    E_ICON_BASE =E_CONTROL_BASE +200,

    E_ICON_LOGO,//	1	公司logo
    E_ICON_NET,//	2	网络图标

    E_ICON_GUN = E_ICON_BASE+10,
    /*
    E_ICON_GUN+1	 = 10	充电枪1图标
    E_ICON_GUN+2		充电枪2图标
    ...		...
    E_ICON_GUN+n		充电枪n图标
    */

//RTC控件类		
    E_RTC_BASE = E_CONTROL_BASE + 230,
    E_RTC_TIME,//	1	界面时间
    E_RTC_CNT,//	2	倒计时

//二维码控件
    E_QRCODE_BASE = E_CONTROL_BASE+240,
    E_QRCODE_WECHAT ,//1	扫码关注
    E_QRCODE_CHARGING,//2	扫码充电

//进度条控件类		
    E_PROGRESS_BASE = E_CONTROL_BASE+250,
    E_PROGRESS_SOC,//	1	充电soc

//后备添加的		
    E_BACKUP_BASE  = E_CONTROL_BASE+270,
    E_TEXT_KWH,//	1	充电功率
    E_TEXT_ELECPCS,//	2	当前电费单价
    E_TEXT_SERVERPCS,//	3	当前服务费单价
    E_TEXT_ELECCOST,//	4	累计充电电费
    E_TEXT_SERVERCOST,//5	累计充电服务费
    E_TEXT_TOTALCOST,//	6	累计总费用
    E_BUTTON_CHARGEINFO,//7	充电信息控件
    E_BUTTON_COSTINFO,//8	费用信息控件
    E_TEXT_REMAINTIMESECOND//9   剩余时间文本
};

#define GUI_VER "DACAI_GTC_1.1.1.1"

static struct t_gtcscreen gtcscreen;

static struct t_contrilmsg contrilmsgbuf[] =
{
// screenid controlid  hide value *str *deal;
//主界面单枪

   {E_SCREEN_MAIN_WAITGUN,E_BUTTON_MANAGE,0,0,0,(uint8 *)&gtcscreen._mainwaitgun.screendeal},
   {E_SCREEN_MAIN_WAITGUN,E_TEXT_TITLE1,0,0,0,0},
   {E_SCREEN_MAIN_WAITGUN,E_TEXT_TITLE2,0,0,0,0},
   {E_SCREEN_MAIN_WAITGUN,E_TEXT_TELRPHONE,0,0,0,0},
   {E_SCREEN_MAIN_WAITGUN,E_TEXT_WEB,0,0,0,0},
   {E_SCREEN_MAIN_WAITGUN,E_TEXT_VERUI,0,0,0,0},
   {E_SCREEN_MAIN_WAITGUN,E_TEXT_VERSOFTWARE,0,0,0,0},
   {E_SCREEN_MAIN_WAITGUN,E_QRCODE_WECHAT,0,0,0,0},
//主界面双枪
   {E_SCREEN_MAIN_DOUBLE, E_BUTTON_MANAGE,0,0,0,(uint8 *)&gtcscreen._maindouble.screendeal},
   {E_SCREEN_MAIN_DOUBLE,E_TEXT_TITLE1,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE,E_TEXT_TITLE2,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE,E_BUTTON_GUN+1,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE, E_ICON_GUN+1,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE,E_BUTTON_GUN+2,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE, E_ICON_GUN+2,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE,E_TEXT_TELRPHONE,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE,E_TEXT_WEB,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE,E_TEXT_VERUI,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE, E_TEXT_VERSOFTWARE,0,0,0,0},
   {E_SCREEN_MAIN_DOUBLE, E_QRCODE_WECHAT,0,0,0,0},
//选择启动方式界面
   {E_SCREEN_WAYSELECT,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._wayselect.screendeal},
   {E_SCREEN_WAYSELECT,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WAYSELECT,E_RTC_CNT,0,0,0,0},
   {E_SCREEN_WAYSELECT,E_QRCODE_CHARGING,0,0,0,0},
   {E_SCREEN_WAYSELECT,E_BUTTON_CANCEL,0,0,0,0},
   {E_SCREEN_WAYSELECT,E_TEXT_REMAINTIMESECOND,0,0,0,0},
//等待输入密码界面
   {E_SCREEN_WAITPWD,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._waitpwd.screendeal},
   {E_SCREEN_WAITPWD,E_RTC_CNT,0,0,0,0},
   {E_SCREEN_WAITPWD,E_TEXT_CARDNO,0,0,gtcscreen._waitpwd.cardno,0},
   {E_SCREEN_WAITPWD,E_TEXT_PASSWORD,0,0,gtcscreen._waitpwd.password,0},
   {E_SCREEN_WAITPWD,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WAITPWD,E_BUTTON_MAKESURE,0,0,0,0},
   {E_SCREEN_WAITPWD,E_BUTTON_CANCEL,0,0,0,0},
//设置充电类型界面
   {E_SCREEN_WORKTYPE_SET,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._worktypeset.screendeal},
   {E_SCREEN_WORKTYPE_SET,E_RTC_CNT,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_BYAUTO,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_BYTIME,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_BYPOWER,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_CANCEL,0,0,0,0},
//设置充电参数界面
    {E_SCREEN_WORKVALUE_SET,E_RTC_CNT,0,0,0,(uint8 *)&gtcscreen._workvalueset.screendeal},
    {E_SCREEN_WORKVALUE_SET,E_TEXT_PARASET_TITLE,0,0,0,0},
    {E_SCREEN_WORKVALUE_SET,E_TEXT_PARASET_VALUE,0,0,gtcscreen._workvalueset.workvalue,0},
    {E_SCREEN_WORKVALUE_SET,E_TEXT_PARASET_UNIT,0,0,0,0},
    {E_SCREEN_WORKVALUE_SET,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_WORKVALUE_SET,E_BUTTON_MAKESURE,0,0,0,0},
    {E_SCREEN_WORKVALUE_SET,E_BUTTON_RETURN,0,0,0,0},
//等待枪连接界面
    {E_SCREEN_WAITGUN,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._waitgun.screendeal},
    {E_SCREEN_WAITGUN,E_TEXT_REMAINTIMESECOND,0,0,0,0},
    {E_SCREEN_WAITGUN,E_RTC_CNT,0,0,0,0},
    {E_SCREEN_WAITGUN,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_WAITGUN, E_BUTTON_CANCEL,0,0,0,0},
//充电中界面(交流)
    {E_SCREEN_CHARGING_AC,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._chargingac.screendeal},
    {E_SCREEN_CHARGING_AC,E_BUTTON_CHARGEINFO,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_BUTTON_COSTINFO,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_TEXT_TIME_USE,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_TEXT_POWERUSE,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_TEXT_OUTPUT_VOLTAGE,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_TEXT_OUTPUT_CUEERNT,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_TEXT_KWH,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_TEXT_STATE,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_BUTTON_STOP,0,0,0,0},
    {E_SCREEN_CHARGING_AC,E_BUTTON_RETURN,0,0,0,0},
//充电中界面(直流)
    {E_SCREEN_CHARGING_DC,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._chargingdc.screendeal},
    {E_SCREEN_CHARGING_DC,E_BUTTON_CHARGEINFO,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_BUTTON_COSTINFO,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_DEMAND_VOLTAGE,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_DEMAND_CURRENT,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_REMAINTIME,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_SOC,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_POWERUSE,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_STATE,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_OUTPUT_VOLTAGE,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_OUTPUT_CUEERNT,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_TEXT_TIME_USE,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_BUTTON_STOP,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_PROGRESS_SOC,0,0,0,0},
    {E_SCREEN_CHARGING_DC,E_BUTTON_RETURN,0,0,0,0},
//充电中界面_费用信息
    {E_SCREEN_CHARGING_COST,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._charingcost.screendeal},
    {E_SCREEN_CHARGING_COST,E_BUTTON_CHARGEINFO,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_BUTTON_COSTINFO,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_ELECPCS,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_SERVERPCS,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_ELECCOST,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_SERVERCOST,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_TOTALCOST,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_BUTTON_RETURN,0,0,0,0},
//结算界面
    {E_SCREEN_SETTLE,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._settle.screendeal},
    {E_SCREEN_SETTLE,E_RTC_CNT,0,0,0,0},
    {E_SCREEN_SETTLE,E_TEXT_TOTAL_POWER,0,0,0,0},
    {E_SCREEN_SETTLE,E_TEXT_TOTAL_TIME,0,0,0,0},
    {E_SCREEN_SETTLE,E_TEXT_TOTAL_COST,0,0,0,0},
    {E_SCREEN_SETTLE,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_SETTLE,E_BUTTON_RETURN,0,0,0,0},
//告警界面
    {E_SCREEN_ALARM,E_TEXT_GUNNO,0,0,0,(uint8 *)&gtcscreen._alarm.screendeal},
    {E_SCREEN_ALARM,E_RTC_CNT,0,0,0,0},
    {E_SCREEN_ALARM,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_ALARM,E_BUTTON_RETURN,0,0,0,0},
    {E_SCREEN_ALARM,E_TEXT_REMAINTIMESECOND,0,0,0,0},
    {E_SCREEN_ALARM,E_TEXT_TITLE1,0,0,0,0},
//等待输入密码界面(管理界面)
    {E_SCREEN_WAITPWD_MANAGE,E_TEXT_PASSWORD,0,0,gtcscreen._managewaitpwd.password,(uint8 *)&gtcscreen._managewaitpwd.screendeal},
    {E_SCREEN_WAITPWD_MANAGE,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_WAITPWD_MANAGE,E_BUTTON_MAKESURE,0,0,0,0},
    {E_SCREEN_WAITPWD_MANAGE,E_BUTTON_CANCEL,0,0,0,0},
//管理选择界面
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_SYSSET,0,0,0,(uint8 *)&gtcscreen._manageselect.screendeal},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_REBOOT,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_RECORDCHECK,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_DEBUG,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_ABOUTDEV,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_BACKUP+1,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_BACKUP+2,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_BACKUP+3,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_BACKUP+4,0,0,0,0},
    {E_SCREEN_MANAGE_SELECT,E_BUTTON_CANCEL,0,0,0,0},
//参数设置界面
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_PAGENO,0,0,0,(uint8 *)&gtcscreen._sysvalueset.screendeal},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_PAGETOTAL,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_BUTTON_SAVE,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_BUTTON_FRONT,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_BUTTON_NEXT,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_BUTTON_RETURN,0,0,0,0},

    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+1,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+2,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+3,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+4,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+5,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+6,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+7,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+8,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+9,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+10,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+11,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+12,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+13,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+14,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+15,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+16,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+17,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+18,0,0,0,0},

    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+1,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+2,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+3,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+4,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+5,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+6,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+7,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+8,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+9,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+10,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+11,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+12,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+13,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+14,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+15,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+16,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+17,0,0,0,0},
    {E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+18,0,0,0,0},
//记录查看界面
    {E_SCREEN_RECORD_CHECK,E_TEXT_PAGENO,0,0,0,(uint8 *)&gtcscreen._recordcheck.screendeal},
    {E_SCREEN_RECORD_CHECK,E_TEXT_PAGETOTAL,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_BUTTON_FRONT,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_BUTTON_NEXT,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_BUTTON_RETURN,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_RECORDTYPE,0,0,gtcscreen._recordcheck.recordtype,0},
    

    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+1,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+2,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+3,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+4,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+5,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+6,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+7,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+8,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+9,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+10,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+11,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+12,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+13,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+14,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+15,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+16,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+17,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+18,0,0,0,0},

    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+1,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+2,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+3,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+4,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+5,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+6,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+7,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+8,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+9,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+10,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+11,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+12,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+13,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+14,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+15,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+16,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+17,0,0,0,0},
    {E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+18,0,0,0,0},
//询问窗口
    {E_SCREEN_COMMUNICATE,E_TEXT_TITLE1,0,0,0,(uint8 *)&gtcscreen._communicate.screendeal},
    {E_SCREEN_COMMUNICATE,E_RTC_CNT,0,0,0,0},
	  {E_SCREEN_COMMUNICATE,E_BUTTON_CANCEL,0,0,0,0},
    {E_SCREEN_COMMUNICATE,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_COMMUNICATE,E_BUTTON_MAKESURE,0,0,0,0},
    {E_SCREEN_COMMUNICATE,E_BUTTON_RETURN,0,0,0,0},
};

struct t_contrilmsg *MEM_GETCONTROLID(uint32 screenid,uint32 controlid)
{
    uint32 len = sizeof(contrilmsgbuf)/sizeof(struct t_contrilmsg);
    return memgetcontrolid(contrilmsgbuf,len,screenid,controlid);
}

struct t_screendeal *MEM_GETDEAL(uint32 screenid)
{
    uint32 len = sizeof(contrilmsgbuf)/sizeof(struct t_contrilmsg);
    return memgetdeal(contrilmsgbuf,len,screenid);
}

static uint8 isequal(const char *src, const char *dst)
{
   if(strlen(dst) == 0)
   {
       return 0;
   }
   if(strlen(src) != strlen(dst))
   {
       return 0;
   }
   return (strncmp(src, dst, strlen(dst)) == 0);
}
static uint8 isgunnoover(char *gunno)
{
    uint32 tmpgunno = atoi(gunno);
    if(tmpgunno > atoi(gtcscreen.screendata.proinitmsg.gunnum))
    {
       return 1;
    }
    return 0;
}

static uint8 issinglegun(void)
{
    char *tmpgunnum = gtcscreen.screendata.proinitmsg.gunnum;
    if(isequal(tmpgunnum,"1"))
    {
       return 1;
    }
    return 0;
}

static uint8 isgunconnect(uint8 gunno)
{
	  if(gunno <=0 ||
			 gunno > atoi(gtcscreen.screendata.proinitmsg.gunnum))
		{
			 return  0;
		}
    char *tmpconnectstate = gtcscreen.screendata.gunmsg[gunno-1].yx.connectstate;
    if(isequal(tmpconnectstate,"connect"))
    {
       return 1;
    }
    return 0;
}
static void hidecontrolsingle(void)
{
    if(!issinglegun())
    {
        return ;
    } 

    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_TEXT_REMAINTIMESECOND),0);
    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_RTC_CNT),0);
    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_BUTTON_CANCEL),0);

    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_TEXT_REMAINTIMESECOND),0);
    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_RTC_CNT),0);
    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_BUTTON_CANCEL),0);

    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_BUTTON_RETURN),0);

    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_DC,E_BUTTON_RETURN),0);

    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_COST,E_BUTTON_RETURN),0);
}

static void setgunselect(uint32 gunselect)
{
   gtcscreen.gunselect = gunselect;

   char gunno[10] = {0};
   sprintf(gunno,"%d",gtcscreen.gunselect);


   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_TEXT_GUNNO),gunno);


   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_GUNNO),gunno);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WORKTYPE_SET,E_TEXT_GUNNO),gunno);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_TEXT_GUNNO),gunno);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_TEXT_GUNNO),gunno);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_CHARGING_DC,E_TEXT_GUNNO),gunno);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_CHARGING_COST,E_TEXT_GUNNO),gunno);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_SETTLE,E_TEXT_GUNNO),gunno);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_GUNNO),gunno);
}

static void changetoscreen(uint32 screen)
{
   gtcscreen.screennow = screen;
 
   
   struct t_contrilmsg icon = {0};
   icon.screenid = gtcscreen.screennow;
   icon.controlid = gtcscreen.logo;
   men_seticonvalue(&icon,gtcscreen.screendata.companydesc.icon);
   
   struct t_contrilmsg companyname = {0};
   companyname.screenid = gtcscreen.screennow;
   companyname.controlid = gtcscreen.companyname;
   mem_settextvalue(&companyname,gtcscreen.screendata.companydesc.name);
   
   char *pnetstate = gtcscreen.screendata.gunmsg[0].yx.netstate;
   uint32 netvalue = 0;
   if(isequal(pnetstate,"netoff"))
   {
       netvalue = 0;
   }
   else if(isequal(pnetstate,"neton"))
   {
        netvalue = 1;
   }
   struct t_contrilmsg net = {0};
   net.screenid = gtcscreen.screennow;
   net.controlid = gtcscreen.netlogo;
   men_seticonvalue(&net,netvalue);
   
   char tmpdevnum[50] = {0};
   sprintf(tmpdevnum,"桩编号:%s",gtcscreen.screendata.proinitmsg.devnum);
   struct t_contrilmsg devnum = {0};
   devnum.screenid = gtcscreen.screennow;
   devnum.controlid = gtcscreen.devnum;
   mem_settextvalue(&devnum,tmpdevnum);
   
   mem_setscreen(screen);
	 
   struct t_screendeal *deal = MEM_GETDEAL(screen);
   if(deal && deal->_initscreen)
   {
        deal->_initscreen();
   }
}

static void changetoscreencharging(void)
{
   char *pdevtype = gtcscreen.screendata.proinitmsg.devtype;

   if(isequal(pdevtype,"ac"))//如果是交流设备
   {
     changetoscreen(E_SCREEN_CHARGING_AC);
   }
   else if(isequal(pdevtype,"dc"))//如果是直流设备
   {
      changetoscreen(E_SCREEN_CHARGING_DC);
   }
}
static void changetocommunicatestop(void)
{
   sprintf(gtcscreen._communicate.type,COMMUNICATESTOP);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_COMMUNICATE,E_TEXT_TITLE1),"停止充电");

   char poingmsg[50] = {0};
   sprintf(poingmsg,"是否停止 %d 号枪 充电",gtcscreen.gunselect);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_COMMUNICATE,E_TEXT_POINTMSG),poingmsg);

   changetoscreen(E_SCREEN_COMMUNICATE);
}
static void poingmsgscreenmsg(char *title,char *poingmsg)
{
   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_REMAINTIMESECOND),0);
   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT),0);
   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_BUTTON_RETURN),0);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_TITLE1),title);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_POINTMSG),poingmsg);

   sprintf(gtcscreen._alarm.screentype,"NONE");

   changetoscreen(E_SCREEN_ALARM);
}

static void startauthfail(char *title,char *poingmsg)
{
   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_REMAINTIMESECOND),0);
   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT),0);
   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_BUTTON_RETURN),0);

   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_TITLE1),title);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_POINTMSG),poingmsg);

   sprintf(gtcscreen._alarm.screentype,"startfail");

   changetoscreen(E_SCREEN_ALARM);
}


static void reloadingmainwaitgun(void)
{
    char *pdevtype = gtcscreen.screendata.proinitmsg.devtype;
	char *pdevver = gtcscreen.screendata.proinitmsg.devver;

    char tmpdevtype[50] = {0};
    if(isequal(pdevtype,"ac"))
    {
       sprintf(tmpdevtype,"交流");
    }
    else if(isequal(pdevtype,"dc"))
    {
       sprintf(tmpdevtype,"直流");
    }
	char tmpbuf[100] = {0};  
	sprintf(tmpbuf,"欢迎使用本公司%s充电设备",tmpdevtype);
	
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_TEXT_TITLE1),tmpbuf);
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_TEXT_TITLE2),"如需充电请先连接充电枪");
   
   char devver[30] = {0};
   sprintf(devver,"%s",pdevver);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_TEXT_VERSOFTWARE),devver);
   
   char guiver[30] = {0};
   sprintf(guiver,"%s",GUI_VER);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_TEXT_VERUI),guiver);
   
   char *pcode = gtcscreen.screendata.companydesc.qrcode;
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_QRCODE_WECHAT),pcode);
}
static void reloadingmaindouble(void)
{
	
    char *pdevtype = gtcscreen.screendata.proinitmsg.devtype;
	char *pdevver = gtcscreen.screendata.proinitmsg.devver;

    char tmpdevtype[50] = {0};
    if(isequal(pdevtype,"ac"))
    {
       sprintf(tmpdevtype,"交流");
    }
    else if(isequal(pdevtype,"dc"))
    {
       sprintf(tmpdevtype,"直流");
    }
	char tmpbuf[100] = {0};  
	sprintf(tmpbuf,"欢迎使用本公司%s充电设备",tmpdevtype);
	
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_TEXT_TITLE1),tmpbuf);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_TEXT_TITLE2),"如需充电请选择充电枪");
   
   char devver[30] = {0};
   sprintf(devver,"%s",pdevver);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_TEXT_VERSOFTWARE),devver);
   
   char guiver[30] = {0};
   sprintf(guiver,"%s",GUI_VER);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_TEXT_VERUI),devver);
   
   char *pcode = gtcscreen.screendata.companydesc.qrcode;
   mem_setqrcodevalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_QRCODE_WECHAT),(uint8 *)pcode);
}
static void reloadingwayselect(void)
{   

  beginrtc(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_RTC_CNT),120);
  
  uint32 pos = gtcscreen.gunselect-1;
  char *pcode = gtcscreen.screendata.gunmsg[pos].gunqrcode;
                                               
  mem_setqrcodevalue(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_QRCODE_CHARGING),(uint8 *)pcode);
  mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_TEXT_POINTMSG),"如需充电请刷卡或扫码");
}
static void reloadingwaitpwd(void)
{   
    beginrtc(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_RTC_CNT),120);
    mem_cleartext(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_PASSWORD));
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_POINTMSG),"请 注 意 遮 挡 键 盘");
}
static void reloadingworktypeset(void)
{
    beginrtc(MEM_GETCONTROLID(E_SCREEN_WORKTYPE_SET,E_RTC_CNT),120);
}
static void reloadingworkvalueset(void)
{	 
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_TEXT_PARASET_TITLE),"设 置 充 电 时 长 为 ");
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_TEXT_PARASET_UNIT),"分钟");
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_TEXT_POINTMSG),"分钟");
    mem_cleartext(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_TEXT_PARASET_VALUE));
}
static void reloadingwaitgun(void)
{
  beginrtc(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_RTC_CNT),200);
}
static void reloadingchargeac(void)
{
    uint32 pos = gtcscreen.gunselect-1;
    struct t_prodevyc *yc = &gtcscreen.screendata.gunmsg[pos].yc;
    uint32 screenid = E_SCREEN_CHARGING_AC;

    mem_controlenable(MEM_GETCONTROLID(screenid,E_BUTTON_CHARGEINFO),0);

    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TIME_USE),yc->charingtime);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_POWERUSE),yc->chargingpower);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_VOLTAGE),yc->outputvoltage);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_CUEERNT),yc->outputcurrent);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_KWH),yc->outputkwh);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_STATE),yc->devstate);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_POINTMSG),yc->chargingpoingmsg);
}
static void reloadingchargedc(void)
{
    uint32 pos = gtcscreen.gunselect-1;
    struct t_prodevyc *yc = &gtcscreen.screendata.gunmsg[pos].yc;
    uint32 screenid = E_SCREEN_CHARGING_DC;

    mem_controlenable(MEM_GETCONTROLID(screenid,E_BUTTON_CHARGEINFO),0);

    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_DEMAND_VOLTAGE),yc->demandvoltage);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_DEMAND_CURRENT),yc->demandcurrent);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_REMAINTIME),yc->remaintime);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_SOC),yc->soc);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_POWERUSE),yc->chargingpower);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_STATE),yc->devstate);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_POINTMSG),yc->chargingpoingmsg);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_VOLTAGE),yc->outputvoltage);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_CUEERNT),yc->outputcurrent);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TIME_USE),yc->charingtime);

}
static void reloadingchargecost(void)
{
    uint32 pos = gtcscreen.gunselect-1;
    struct t_prodevyc *yc = &gtcscreen.screendata.gunmsg[pos].yc;
    uint32 screenid = E_SCREEN_CHARGING_COST;

    mem_controlenable(MEM_GETCONTROLID(screenid,E_BUTTON_COSTINFO),0);

    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_ELECPCS),yc->elecpcs);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_SERVERPCS),yc->serverpcs);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_ELECCOST),yc->eleccost);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_SERVERCOST),yc->servercost);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTALCOST),yc->totalcost);
}
static void reloadingsettle(void)
{
    uint32 pos = gtcscreen.gunselect-1;
    struct t_prodevyc *yc = &gtcscreen.screendata.gunmsg[pos].yc;
    uint32 screenid = E_SCREEN_SETTLE;

    beginrtc(MEM_GETCONTROLID(screenid,E_RTC_CNT),5);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_COST),yc->settlecost);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_POWER),yc->settlepower);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_TIME),yc->settletime);
}
static void reloadingalarm(void)
{
   beginrtc(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT),60);	
}
static void reloadingmanagewaitpwd(void)
{
    mem_cleartext(MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_TEXT_PASSWORD));
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_TEXT_POINTMSG),"请 注 意 遮 挡 键 盘");
}
static void reloadingselectmanage(void)
{

}
static void reloadingtypevalueset(void)
{
    uint32 i;
    for(i = 0;i<MANAGEMAX;i++)
    {
       mem_cleartext(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+i+1));
       mem_cleartext(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+i+1));
       mem_controlenable(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+i+1),0);
    }
    gtcscreen._sysvalueset.pageno = 1;
    gtcscreen._sysvalueset.pagetotal = 0;
    gtcscreen._sysvalueset.cnt = 0;
    gtcscreen._sysvalueset.maxcnt = MANAGEMAX/TYPEVALUEGETMAX;
    gtcscreen._sysvalueset.pagetotal = 0;
    memset(gtcscreen._sysvalueset.driver,0,sizeof(gtcscreen._sysvalueset.driver));
    gtcscreen._sysvalueset.flag = 0;
    gtcscreen._sysvalueset.flagread = 0;
    memset(gtcscreen._sysvalueset.type,0,sizeof(gtcscreen._sysvalueset.type));
    memset(gtcscreen._sysvalueset.value,0,sizeof(gtcscreen._sysvalueset.value));

    char pagenobuf[10];
    sprintf(pagenobuf,"%d",gtcscreen._sysvalueset.pageno);
    mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_PAGENO),pagenobuf);
}
static void reloadingrecordcheck(void)
{
   uint32 i = 0;
   for(i = 0;i<MANAGEMAX;i++)
   {
     mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+i+1));
     mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+i+1));
   }
	 
	 mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_PAGENO));
   mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_PAGETOTAL));
	 mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_RECORDTYPE));
	 
	 gtcscreen._recordcheck.pageno = 0;
   gtcscreen._recordcheck.pagetotal = 0;
	 
	 
}
static void reloadingdebug(void)
{

}
static void reloadingcommunicate(void)
{
   beginrtc(MEM_GETCONTROLID(E_SCREEN_COMMUNICATE,E_RTC_CNT),10);
}

static void resetscreen()
{
    if(issinglegun())
    {     
      setgunselect(1);
    }
    else
    {
       setgunselect(0);
    }
    changetoscreen(E_SCREEN_MAIN_WAITGUN);
}
static void changetoscreenalarm(void)
{
   if(issinglegun())
   {
      mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_REMAINTIMESECOND),0);
      mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT),0);
      mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_BUTTON_RETURN),0);
   }
   else
   {
       mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_REMAINTIMESECOND),1);
       mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT),1);
       mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_BUTTON_RETURN),1);
   }
   sprintf(gtcscreen._alarm.screentype,"%s",ALARMMSG);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_TITLE1),"设备故障,暂停使用");

   changetoscreen(E_SCREEN_ALARM);

}


static void pollmainwaitgun(void)
{
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_BUTTON_MANAGE)))//被触发
    {
      changetoscreen(E_SCREEN_WAITPWD_MANAGE);
		 
      return ;
    }

    if(issinglegun())
    {
      if(isgunconnect(gtcscreen.gunselect))
      {
        changetoscreen(E_SCREEN_WAYSELECT);
      }
    }
    else
    {
      uint32 i = 0;
      for(i = 0;i<TOTALGUN;i++)
      {
         if(isgunconnect(i+1))
         {
           changetoscreen(E_SCREEN_MAIN_DOUBLE);
         }
      }
    }
}

static void dealgunselect(void)
{
    uint32 gunno = gtcscreen.gunselect;
    uint32 pos = gunno-1;
    char *pgunstate = gtcscreen.screendata.gunmsg[pos].yx.gunstate;
    if (isequal(pgunstate,"idle")){//空闲状态
       if (isgunconnect(gtcscreen.gunselect)){//如果枪已经连接
           changetoscreen(E_SCREEN_WAYSELECT);//切换到等待选择充电类型界面
          }else{
           changetoscreen(E_SCREEN_WAITGUN);//切换到等待枪连接状态
          }
    }
    else if(isequal(pgunstate,"charging")){//当前状态为充电状态
        changetoscreencharging();
    }
    else if(isequal(pgunstate,"alarm")){//当前状态为告警状态
        changetoscreenalarm();//切换到等待枪连接状态
    }
}
static void pollmaindouble(void)
{  
    uint32 i = 0;

    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_BUTTON_MANAGE)))//被触发
    {
      changetoscreen(E_SCREEN_WAITPWD_MANAGE);
    }
    for(i = 0;i<TOTALGUN;i++)
    {
      if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_BUTTON_GUN+i+1)))
      {
        setgunselect(i+1);
        dealgunselect();
      }
    }
    uint32 value = 0;
    for(i = 0;i<TOTALGUN;i++)
    {
       if(isgunconnect(i+1))
       {
           value = 1;
       }
    }
    if(!value)
    {
      resetscreen();
    }
    
}
static void pollwayselect(void)
{
    struct t_contrilmsg *pcnt = MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_RTC_CNT);
    struct t_contrilmsg *pcancel = MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_BUTTON_CANCEL);
	 
    if(isrtctimeout(pcnt) || 
        isbutton_trigger(pcancel) ||
        !isgunconnect(gtcscreen.gunselect))
    {
       resetscreen();  
    }
}
static void pollwaitpwd(void)
{		
    struct t_contrilmsg *pcnt = MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_RTC_CNT);
    struct t_contrilmsg *pcancel = MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_BUTTON_CANCEL);
	
    if(isrtctimeout(pcnt) || 
       isbutton_trigger(pcancel) ||
        !isgunconnect(gtcscreen.gunselect))
    {
       resetscreen();
	   return ;
    }
}
static void pollworktypeset(void)
{
    struct t_contrilmsg *pcnt = MEM_GETCONTROLID(E_SCREEN_WORKTYPE_SET,E_RTC_CNT);
    struct t_contrilmsg *ppower = MEM_GETCONTROLID(E_SCREEN_WORKTYPE_SET,E_BUTTON_BYPOWER);
    struct t_contrilmsg *ptime = MEM_GETCONTROLID(E_SCREEN_WORKTYPE_SET,E_BUTTON_BYTIME);
    struct t_contrilmsg *pcancel = MEM_GETCONTROLID(E_SCREEN_WORKTYPE_SET,E_BUTTON_CANCEL);

    char *p  = gtcscreen._worktypeset.worktype;
    if(isbutton_trigger(ppower))
    {
       sprintf(p,"bypower");
       changetoscreen(E_SCREEN_WORKVALUE_SET);
    }
    else if(isbutton_trigger(ptime))
    {
      sprintf(p,"bytime");
      changetoscreen(E_SCREEN_WORKVALUE_SET);
    }

    if(isrtctimeout(pcnt) || isbutton_trigger(pcancel))
    {
       resetscreen();
    }
}
static void pollworkvalueset(void)
{
    struct t_contrilmsg *pcnt = MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_RTC_CNT);
    struct t_contrilmsg *pretur = MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_BUTTON_RETURN);
	
    if(isbutton_trigger(pretur))
    {
	   changetoscreen(E_SCREEN_WORKTYPE_SET);
    }	
    if(isrtctimeout(pcnt))
    {
       resetscreen();
    }
}
static void pollwaitgun(void)
{   
    struct t_contrilmsg *pcnt = MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_RTC_CNT);
    struct t_contrilmsg *pcancel = MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_BUTTON_CANCEL);
	
    if(isrtctimeout(pcnt)|| 
	   isbutton_trigger(pcancel))
    {
         resetscreen();
    }
    if(isgunconnect(gtcscreen.gunselect) )
    {
      changetoscreen(E_SCREEN_WAYSELECT);
    }
}
static void SETTEXT(struct t_contrilmsg *text,char *dst,char *src)
{
    if(strlen(src) == 0)
    {
       return ;
    }

    if(isequal(dst,src))
    {
      return ;
    }
    mem_settextvalue(text,src);
}

static void SETPROGRESS(struct t_contrilmsg *progress ,char *dst,char *src)
{
    if(strlen(src) == 0)
    {
       return ;
    }
	 
    char tmpsrc[20] = {0};
    sprintf(tmpsrc,"%s",src);

	char tmpdst[20] = {0};
    sprintf(tmpdst,"%s",dst);

    if(isequal(dst,src))
    {
      return ;
    }
	
    uint32 pos = strlen(tmpsrc)-1;
    tmpsrc[pos] = 0;

    uint32 soc = atoi(tmpsrc);

    mem_setprogressvalue(progress,soc);

}

static void pollchargingac(void)
{
    struct t_contrilmsg *pcostinfo = MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_BUTTON_COSTINFO);
    struct t_contrilmsg *pretur = MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_BUTTON_RETURN);
    struct t_contrilmsg *pstop = MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_BUTTON_STOP);
	
    if(isbutton_trigger(pcostinfo))
    {
	   changetoscreen(E_SCREEN_CHARGING_COST);
    }	
	if(isbutton_trigger(pretur))
    {
	   resetscreen();
    }	
    if(isbutton_trigger(pstop))
    {
       changetocommunicatestop();
    }
}
static void pollchargingdc(void)
{
    struct t_contrilmsg *pcostinfo = MEM_GETCONTROLID(E_SCREEN_CHARGING_DC,E_BUTTON_COSTINFO);
    struct t_contrilmsg *pretur = MEM_GETCONTROLID(E_SCREEN_CHARGING_DC,E_BUTTON_RETURN);
    struct t_contrilmsg *pstop = MEM_GETCONTROLID(E_SCREEN_CHARGING_DC,E_BUTTON_STOP);

    if(isbutton_trigger(pcostinfo))
    {
	   changetoscreen(E_SCREEN_CHARGING_COST);
    }	
    if(isbutton_trigger(pretur))
    {
	   resetscreen();
    }	
    if(isbutton_trigger(pstop))
    {
       changetocommunicatestop();
    }
	
}
static void pollchargingcost(void)
{
    struct t_contrilmsg *pcharginginfo = MEM_GETCONTROLID(E_SCREEN_CHARGING_COST,E_BUTTON_CHARGEINFO);
    struct t_contrilmsg *pretur = MEM_GETCONTROLID(E_SCREEN_CHARGING_COST,E_BUTTON_RETURN);
    if(isbutton_trigger(pcharginginfo))
    {  
        changetoscreencharging();
    }
    if(isbutton_trigger(pretur))
    {
	   resetscreen();
    }	 
}
static void pollsettle(void)
{
    if(isrtctimeout(MEM_GETCONTROLID(E_SCREEN_SETTLE,E_RTC_CNT)) ||
      (isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_SETTLE,E_BUTTON_RETURN))))
    {
       resetscreen();	   
    }

}
static void pollalarm(void)
{
    if(isrtctimeout(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT)) || isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_ALARM,E_BUTTON_RETURN)))
    {
       resetscreen();
    }
		if(isequal(gtcscreen._alarm.screentype,"startfail") &&
			 !isgunconnect(gtcscreen.gunselect))
		{ 
			  resetscreen();
		}
}
static void pollmanagewaitpwd(void)
{
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_BUTTON_CANCEL)))
    {
       resetscreen();
    }
}
static void pollmanageselect(void)
{
  if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MANAGE_SELECT,E_BUTTON_CANCEL)))
  {
      resetscreen();
  }
  if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MANAGE_SELECT,E_BUTTON_SYSSET)))
  {
     changetoscreen(E_SCREEN_TYPEVALUE_SET);
  }
  if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MANAGE_SELECT,E_BUTTON_RECORDCHECK)))
  {
     changetoscreen(E_SCREEN_RECORD_CHECK);
  }
}
static void pollmanagesysset(void)
{
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_BUTTON_RETURN)))
    {
        changetoscreen(E_SCREEN_MANAGE_SELECT);
    }
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_BUTTON_SAVE)))
    {
       gtcscreen._sysvalueset.flag = 1;
    }
    if(1 == gtcscreen._sysvalueset.flag)
    {
        uint32 i = 0;
        uint8 *p = gtcscreen._sysvalueset.driver;
        for(i=0;i<MANAGEMAX;i++)
        {
           if(*(p+i))
           {
              mem_sendgettextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+i+1));
              mem_sendgettextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+i+1));
              *(p+i) = 0;
              gtcscreen._sysvalueset.flag = 2;
              return ;
           }
        }
         gtcscreen._sysvalueset.flag = 0;
    }
}
static void pollrecordcheck(void)
{
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_BUTTON_RETURN)))
    {
        changetoscreen(E_SCREEN_MANAGE_SELECT);
    }
}
static void polldebug(void)
{

}
static void pollcommunicate(void)
{
    if(isrtctimeout(MEM_GETCONTROLID(E_SCREEN_COMMUNICATE,E_RTC_CNT)) ||
       isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_COMMUNICATE,E_BUTTON_RETURN)) ||
       isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_COMMUNICATE,E_BUTTON_CANCEL)))
    {
        if(isequal(gtcscreen._communicate.type,COMMUNICATESTOP))
        {
            changetoscreencharging();
        }
    }
}




static uint8 worktypeset_screengetyk(struct t_prodevyk *yk)
{

    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_WORKTYPE_SET,E_BUTTON_BYAUTO)))
    {
        char pselecttype[20] = {0};
        sprintf(pselecttype,"auto");

        sprintf(yk->gunno,"%d",gtcscreen.gunselect);
        sprintf(yk->yk_type,"%s","startcharge");
        sprintf(yk->start_type,"%s",pselecttype);

        poingmsgscreenmsg("提 示 信 息","设备启动中......");
        return 1;
    }
		return 0;
}

static uint8 workvalueset_screengetyk( struct t_prodevyk *yk)
{  
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_BUTTON_MAKESURE)))
    {
      char pvalue[50] = {0};
      driver_gettextvalue(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_TEXT_PARASET_VALUE),pvalue);
      uint32 value = atoi(pvalue);
		  if(!strlen(pvalue))
		  {
         mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_TEXT_POINTMSG),"值不能为空");
			 	 return 0;
		  }
		  if(value<=WORKVALUEMIN || value >= WORKVALUEMAX)
		  {
		      char buf[100] = {0};
          sprintf(buf,"请在合理的空间设置(%d-%d)",WORKVALUEMIN,WORKVALUEMAX);
          mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WORKVALUE_SET,E_TEXT_POINTMSG),buf);
		  }
		  else
		  {
          sprintf(yk->gunno,"%d",gtcscreen.gunselect);
          sprintf(yk->yk_type,"%s","startcharge");
          sprintf(yk->start_type,"%s",gtcscreen._worktypeset.worktype);
          sprintf(yk->start_value,"%s",pvalue);
			 
			    poingmsgscreenmsg("提 示 信 息","设备启动中......");
          return 1;
		  }
    }
    return 0;
}
static uint8 manselect_screengetyk(struct t_prodevyk *yk)
{
   if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MANAGE_SELECT,E_BUTTON_REBOOT)))
   {
      sprintf(yk->gunno,"%d",0);
      sprintf(yk->yk_type,"reboot");
      return 1;
   }
   return 0;
}
static uint8 communicate_screengetyk(struct t_prodevyk *yk)
{
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_COMMUNICATE,E_BUTTON_MAKESURE))&&
       isequal(gtcscreen._communicate.type,COMMUNICATESTOP))
    {
        sprintf(yk->gunno,"%d",gtcscreen.gunselect);
        sprintf(yk->yk_type,"%s","stopcharge");
        changetoscreencharging();
        return 1;
    }
    return 0;
}
static uint8 chargingac_updateyc(char * gunno,struct t_prodevyc *yc)
{

    uint32 tmpgunno = atoi(gunno);
    if(tmpgunno !=  gtcscreen.gunselect)
    {
       return  0;
    }
	uint32 pos = tmpgunno -1 ;
	
    struct t_prodevyc *ycdst = &gtcscreen.screendata.gunmsg[pos].yc;
	struct t_prodevyc *ycsrc = yc;

    uint32 screenid = E_SCREEN_CHARGING_AC;
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TIME_USE),ycdst->charingtime,ycsrc->charingtime);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_POWERUSE),ycdst->chargingpower,ycsrc->chargingpower);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_VOLTAGE),ycdst->outputvoltage,ycsrc->outputvoltage);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_CUEERNT),ycdst->outputcurrent,ycsrc->outputcurrent);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_KWH),ycdst->outputkwh,ycsrc->outputkwh);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_STATE),ycdst->devstate,ycsrc->devstate);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_POINTMSG),ycdst->chargingpoingmsg,ycsrc->chargingpoingmsg);
    return 1;
}
static uint8  chargingdc_updateyc(char * gunno,struct t_prodevyc *yc)
{

	uint32 tmpgunno = atoi(gunno);
	if(tmpgunno !=	gtcscreen.gunselect)
	{
	  return  0;
	}
	uint32 pos = tmpgunno -1 ;
		
		
    struct t_prodevyc *ycdst = &gtcscreen.screendata.gunmsg[pos].yc;
	struct t_prodevyc *ycsrc = yc;

    uint32 screenid = E_SCREEN_CHARGING_DC;
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_DEMAND_VOLTAGE),ycdst->demandvoltage,ycsrc->demandvoltage);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_DEMAND_CURRENT),ycdst->demandcurrent,ycsrc->demandcurrent);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_REMAINTIME),ycdst->remaintime,ycsrc->remaintime);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_SOC),ycdst->soc,ycsrc->soc);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_POWERUSE),ycdst->chargingpower,ycsrc->chargingpower);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_STATE),ycdst->devstate,ycsrc->devstate);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_POINTMSG),ycdst->chargingpoingmsg,ycsrc->chargingpoingmsg);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_VOLTAGE),ycdst->outputvoltage,ycsrc->outputvoltage);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_CUEERNT),ycdst->outputcurrent,ycsrc->outputcurrent);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TIME_USE),ycdst->charingtime,ycsrc->charingtime);

    SETPROGRESS(MEM_GETCONTROLID(screenid,E_PROGRESS_SOC),ycdst->soc,ycsrc->soc);
    return 1;
}
static uint8  chargingcost_updateyc(char * gunno,struct t_prodevyc *yc)
{
    uint32 tmpgunno = atoi(gunno);
	if(tmpgunno !=	gtcscreen.gunselect)
	{
	  return  0;
	}
	uint32 pos = tmpgunno -1 ;
		
    struct t_prodevyc *ycdst = &gtcscreen.screendata.gunmsg[pos].yc;
	struct t_prodevyc *ycsrc = yc;

    uint32 screenid = E_SCREEN_CHARGING_COST;
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_ELECPCS),ycdst->elecpcs,ycsrc->elecpcs);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_SERVERPCS),ycdst->serverpcs,ycsrc->serverpcs);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_ELECCOST),ycdst->eleccost,ycsrc->eleccost);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_SERVERCOST),ycdst->servercost,ycsrc->servercost);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTALCOST),ycdst->totalcost,ycsrc->totalcost);
    return 1;
}
static uint8  settle_updateyc(char * gunno,struct t_prodevyc *yc)
{

    uint32 tmpgunno = atoi(gunno);
	if(tmpgunno !=	gtcscreen.gunselect)
	{
	  return 0;
	}
	uint32 pos = tmpgunno -1 ;
		 
		
    struct t_prodevyc *ycdst = &gtcscreen.screendata.gunmsg[pos].yc;
	struct t_prodevyc *ycsrc = yc;

    uint32 screenid = E_SCREEN_SETTLE;

    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_COST),ycdst->settlecost,ycsrc->settlecost);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_POWER),ycdst->settlepower,ycsrc->settlepower);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_TIME),ycdst->settletime,ycsrc->settletime);
    return 1;
}

static uint8  alarm_updateyc(char * gunno,struct t_prodevyc *yc)
{
    uint32 tmpgunno = atoi(gunno);
	if(tmpgunno !=	gtcscreen.gunselect)
	{
      return 0;
	}
    if(!isequal(gtcscreen._alarm.screentype,ALARMMSG))
    {
      return 0;
    }
    uint32 pos = tmpgunno -1;
		
    struct t_prodevyc *ycdst = &gtcscreen.screendata.gunmsg[pos].yc;
	struct t_prodevyc *ycsrc = yc;

    SETTEXT(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_POINTMSG),ycdst->alarminfo,ycsrc->alarminfo);
    return 1;
}
static uint8 waitpwd_getpwdauth(struct t_pwdauth *auth)
{
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_BUTTON_MAKESURE)))
    {     
         char cardno[30] = {0};
         mem_gettextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_CARDNO),cardno);
				 
         char password[30] = {0};
         driver_gettextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_PASSWORD),password);

         mem_cleartext(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_PASSWORD));
         mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_POINTMSG),"验证中,请稍侯.........");

         sprintf(auth->gunno,"%d",gtcscreen.gunselect);
         sprintf(auth->type,"%s","cardauth");
         sprintf(auth->cardno,"%s",cardno);
         sprintf(auth->password,"%s",password);
         return 1;
    }
    return 0;
}

static uint8 manwaitpwd_getpwdauth(struct t_pwdauth *auth)
{
    if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_BUTTON_MAKESURE)))
    {      
       char pwd[30] = {0};
       driver_gettextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_TEXT_PASSWORD),pwd);

       mem_cleartext(MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_TEXT_PASSWORD));
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_TEXT_POINTMSG),"验证中,请稍侯.........");
       sprintf(auth->gunno,"%d",0);
       sprintf(auth->type,"%s","manauth");
       sprintf(auth->password,"%s",pwd);
			 
			 changetoscreen(E_SCREEN_MANAGE_SELECT);
       return 1;
    }
   return 0;
}

static uint8 sysvaluesetgetfilecheck(struct t_filecheck *filecheck)
{
   int *ppageno = &gtcscreen._sysvalueset.pageno;
   int *pcnt = &gtcscreen._sysvalueset.cnt;
   int *pmaxcnt = &gtcscreen._sysvalueset.maxcnt;
   int  unit = TYPEVALUEGETMAX;
   int totalunit = MANAGEMAX;
   uint32 i;

   if(*pcnt < *pmaxcnt)
   {
    uint32 pos = (*ppageno-1)*totalunit +(*pcnt)*unit;
    sprintf(filecheck->filetype,"configure");
    sprintf(filecheck->baseno,"%d",pos);
    sprintf(filecheck->totalnum,"%d",unit);

    *pcnt+=1;
    return 1;
   }

   if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_BUTTON_NEXT)))
   {
       if(*ppageno>=gtcscreen._sysvalueset.pagetotal)
       {
           return 0;
       }

      *ppageno +=1;
      *pcnt = 0;

       char pagenobuf[10];
       sprintf(pagenobuf,"%d",*ppageno);
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_PAGENO),pagenobuf);

       for(i = 0;i<MANAGEMAX;i++)
       {
          mem_cleartext(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+i+1));
          mem_cleartext(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+i+1));
          mem_controlenable(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+i+1),0);
       }

   }
   if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_BUTTON_FRONT)))
   {
       if(*ppageno<=1)
       {
           return 0;
       }
       *ppageno -=1;
       *pcnt = 0;

       char pagenobuf[10];
       sprintf(pagenobuf,"%d",*ppageno);
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_PAGENO),pagenobuf);

       sprintf(filecheck->filetype,"configure");
       sprintf(filecheck->baseno,"%d",*ppageno);
       sprintf(filecheck->totalnum,"%d",TYPEVALUEGETMAX);

       for(i = 0;i<MANAGEMAX;i++)
       {
         mem_cleartext(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+i+1));
         mem_cleartext(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+i+1));
       }
    }
    return 0;
}
struct recordmem
{
	char chinese[50];
	char english[50];
};
static struct recordmem recordmembuf[] = 
{
	{"待上传充电记录","record_waitupload"},
	{"历史充电记录","record_histroy"},
	{"告警记录","record_alarm"},
	{"事件记录","record_events"},
	{"未使用1","unuse1"},
	{"未使用2","unuse2"},
	{"未使用3","unuse3"},
	{"未使用4","unuse4"},
};
char * getrecordtype(char *chinese)
{
	uint32 i = 0;
	uint32 len = sizeof(recordmembuf)/sizeof(struct recordmem);
	for(i=0;i<len;i++)
	{
	  if(isequal(chinese,recordmembuf[i].chinese))
	  {
		  return recordmembuf[i].english;
	  }
	}
    return 0;
}
static uint8 recordgetfilecheck(struct t_filecheck *filecheck)
{
    uint32 i = 0;
    int *pno = &gtcscreen._recordcheck.pageno;
    int *ptotal = &gtcscreen._recordcheck.pagetotal;
    char type[50] = {0};
		
	  driver_gettextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_RECORDTYPE),type);//把读取的记录类型储存到type数组中
	  char *precordtype = getrecordtype(type);//获取数组的英文代称
		
		int ret = driver_texttrigger(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_RECORDTYPE));
		if(ret)
		{
      *pno = 1;
      *ptotal = 0;

      if(!precordtype)
      {
        return 0;
      }
			char pagenobuf[10];
      sprintf(pagenobuf,"%d",*pno);
      mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_PAGENO),pagenobuf);
			
      sprintf(filecheck->filetype,"%s",(uint8 *)precordtype);
      sprintf(filecheck->baseno,"%d",*pno-1);
      sprintf(filecheck->totalnum,"%d",1);
      return 1;
    }
	
		if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_BUTTON_NEXT)))
    {
			 if(0 == *ptotal)
			 {
				  return 0;
			 }
       if(*pno>=5)
       {
           return 0;
       }
      *pno +=1;
    
       char pagenobuf[10];
       sprintf(pagenobuf,"%d",*pno);
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_PAGENO),pagenobuf);

       for(i = 0;i<MANAGEMAX;i++)
       {
          mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+i+1));
          mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+i+1));
       }
			 sprintf(filecheck->filetype,"%s",(uint8 *)precordtype);
       sprintf(filecheck->baseno,"%d",*pno-1);
       sprintf(filecheck->totalnum,"%d",1);
			 
       return 1;
   }
   if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_BUTTON_FRONT)))
   {
		   if(0 == *ptotal)
			 {
				  return 0;
			 }
       if(*pno<=1)
       {
           return 0;
       }
       *pno -=1;

       char pagenobuf[10];
       sprintf(pagenobuf,"%d",*pno);
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_PAGENO),pagenobuf);

       for(i = 0;i<MANAGEMAX;i++)
       {
         mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+i+1));
         mem_cleartext(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+i+1));
       }
			 sprintf(filecheck->filetype,"%s",(uint8 *)precordtype);
       sprintf(filecheck->baseno,"%d",*pno-1);
       sprintf(filecheck->totalnum,"%d",1);
			 return 1;
    }
    return 0;
}
void sysvaluesetfilecheckack(struct t_filecheckack *ack)
{
   if(!isequal("configure",ack->filetype))
   {
       return ;
   }
   uint32 i = 0;
   uint32 baseno = atoi(ack->baseno);
   uint32 readnum = atoi(ack->readnum);
   uint32 pos = baseno % MANAGEMAX;
   uint32 totalnum = atoi(ack->totalnum);
   if(readnum >TYPEVALUEGETMAX ||
      !readnum)
   {
       return ;
   }

   if(totalnum%MANAGEMAX)//
   {
     gtcscreen._sysvalueset.pagetotal = totalnum/MANAGEMAX+1;
   }
   else
   {
     gtcscreen._sysvalueset.pagetotal = (totalnum/MANAGEMAX) ;
   }
   char pagetotalbuf[10] = {0};
   sprintf(pagetotalbuf,"%d", gtcscreen._sysvalueset.pagetotal);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_PAGETOTAL),pagetotalbuf);
   for( i = 0;i<readnum;i++)
   {
     uint32 tmpos = pos+i+1;
     mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANTYPE+tmpos),ack->keyvaluebuf[i].key);
     mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+tmpos),ack->keyvaluebuf[i].value);
     mem_controlenable(MEM_GETCONTROLID(E_SCREEN_TYPEVALUE_SET,E_TEXT_MANVALUE+tmpos),1);
   }
}
void recordgetfilecheckack(struct t_filecheckack *ack)
{
	uint32 i = 0;
	char type[50] = {0};
  driver_gettextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_RECORDTYPE),type);
	if(!isequal(type,ack->filetype))
	{
	 	return ;
	}
	for(i = 0;i<MANAGEMAX;i++)
	{
		 mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANTYPE+i+1),ack->keyvaluebuf[i].key);
     mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_MANVALUE+i+1),ack->keyvaluebuf[i].value);
	}

	mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_RECORD_CHECK,E_TEXT_PAGETOTAL),ack->totalnum);
	uint32 totalnum = atoi(ack->totalnum);
	gtcscreen._recordcheck.pagetotal = totalnum;
	
}
uint8 sysvaluesetfilechange(struct t_filechange *filechange)
{
   uint8 *pflag = &gtcscreen._sysvalueset.flag;
   char *ptype = gtcscreen._sysvalueset.type;
   char *pvalue = gtcscreen._sysvalueset.value;
   if(2 == *pflag)
   {
     if(strlen(ptype) && strlen(pvalue))
     {
         sprintf(filechange->filetype,"configure");
         sprintf(filechange->type,"%s",ptype);
         sprintf(filechange->valuep,"%s",pvalue);
         *pflag = 1;

         memset(ptype,0,sizeof(gtcscreen._sysvalueset.type));
         memset(pvalue,0,sizeof(gtcscreen._sysvalueset.value));
         return 1;

     }
   }
   return 0;
}
void mem_setscreenmsg(char *gunno,char *type,char *str)
{
   if(isgunnoover(gunno))
   {
       return ;
   }
   uint32 tmpgunno = atoi(gunno);
   
   if(isequal(type,"qr_wechat"))
   {
      sprintf(gtcscreen.screendata.companydesc.qrcode,"%s",str);
      mem_setqrcodevalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_QRCODE_WECHAT),(uint8 *)str);
      mem_setqrcodevalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_QRCODE_WECHAT),(uint8 *)str);
   }
   else if(isequal(type,"qr_charging"))
   {    
      uint32 pos = tmpgunno - 1;
      sprintf(gtcscreen.screendata.gunmsg[pos].gunqrcode,"%s",str);
      if(gtcscreen.gunselect == tmpgunno)
      {
         mem_setqrcodevalue(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_QRCODE_CHARGING),(uint8 *)str);
      }
   }
   else if(isequal(type,"telephone"))
   {
       char tele[100] = {0};
       sprintf(tele,"客服电话:%s",str);

       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_TEXT_TELRPHONE),tele);
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_TEXT_TELRPHONE),tele);
   }
   else if(isequal(type,"web"))
   {
       char web[100] = {0};
       sprintf(web,"官方网站:%s",str);
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_TEXT_WEB),web);
       mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_TEXT_WEB),web);
   }
}
static void updatenetstate(char *gunno,char *netstate)
{
   uint32 tmpgunno = atoi(gunno);
   uint32 pos = tmpgunno -1;
   char *pnetstate = gtcscreen.screendata.gunmsg[pos].yx.netstate;
   if(isequal(netstate,pnetstate))
   {
     return ;
   }
   uint8 tmpstate = 0;
   if(isequal(netstate,"netoff"))
   {
       tmpstate = 0;
   }
   else if(isequal(netstate,"neton"))
   {
         tmpstate = 1;
   }
   struct t_contrilmsg  control = {0};
   control.screenid = gtcscreen.screennow;
   control.controlid = gtcscreen.netlogo;
  
   men_seticonvalue(&control,tmpstate);

   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_BUTTON_STOP),!tmpstate);
   mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_DC,E_BUTTON_STOP),!tmpstate);
}
static void updategunstate(char *gunno,char *gunstate)
{  
   uint32 tmpgunno = atoi(gunno);
   uint32 pos = tmpgunno -1;

   char *pgunstate = gtcscreen.screendata.gunmsg[pos].yx.gunstate;
   if(isequal(gunstate,pgunstate))
   {
     return ;
   }
   uint8 tmpstate = 0;

   if(isequal(gunstate,"idle"))
   {
      tmpstate = 0;
   }
   else if(isequal(gunstate,"charging"))
   {
      tmpstate = 1;
   }
   else if(isequal(gunstate,"alarm"))
   {
      tmpstate = 2;
   }
   men_seticonvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_ICON_GUN+tmpgunno),tmpstate);
}

void mem_updatedevyx(const char *gunno,const struct t_prodevyx *yxmsg)
{
   if(isgunnoover((char *)gunno))
   {
        return ;
   }
   uint32 tmpgunno = atoi(gunno);

   char *pgunstate = gtcscreen.screendata.gunmsg[tmpgunno-1].yx.gunstate;
   if(!isequal(pgunstate,yxmsg->gunstate) && atoi(gunno) == gtcscreen.gunselect)//如果是当前枪的状态发生改变
   {
     if(isequal(yxmsg->gunstate,"idle"))//
     {
        resetscreen();
     }
     if(isequal(yxmsg->gunstate,"charging"))//如果是转到充电状态
     {
        changetoscreencharging();//加载为充电界面
     }
     else if(isequal(yxmsg->gunstate,"alarm"))
     {
        changetoscreenalarm();//加载为告警界面
     }
     else if(isequal(yxmsg->gunstate,"settle"))
     {
        changetoscreen(E_SCREEN_SETTLE);
     }
   }
   updatenetstate((char *)gunno,(char *)yxmsg->netstate);
   updategunstate((char *)gunno,(char *)yxmsg->gunstate);
	
   memcpy((void *)&gtcscreen.screendata.gunmsg[tmpgunno-1].yx,(void *)yxmsg,sizeof(struct t_prodevyx));
}

void mem_updatedevyc(const char *gunno,const struct t_prodevyc *ycmsg)
{
    if(isgunnoover((char *)gunno))
    {
        return ;
    }
    uint32 tmpgunno = atoi(gunno);
    uint8 pos = tmpgunno -1 ;
    struct t_prodevyc *pyc = &gtcscreen.screendata.gunmsg[pos].yc;
    if(tmpgunno == gtcscreen.gunselect)
    {
        struct t_screendeal *deal = MEM_GETDEAL(gtcscreen.screennow);
        if(deal && deal->_dealscreenupdateyc)
        {
             deal->_dealscreenupdateyc((char *)gunno,(struct t_prodevyc *)ycmsg);
        }
    }
    memcpy((uint8 *)pyc,(uint8 *)ycmsg,sizeof(struct t_prodevyc));
}

void mem_startauth( char *gunno, struct t_startauth *startauth)
{
    if (atoi(gunno) != gtcscreen.gunselect)
    {
        return ;
    }
    if (isequal(startauth->flag,"authing")){
       if (isequal(startauth->authtype,"qrcode_auth")){
            poingmsgscreenmsg("提 示 信 息","设备启动中......");
       }
    }
    else if(isequal(startauth->flag,"succ"))
    {
       if(isequal(startauth->authtype,"card_auth")){
          if (isequal(startauth->pwdtype,"pwdneed")){          
             mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_CARDNO),startauth->cardno);
             changetoscreen(E_SCREEN_WAITPWD);
          }else if(isequal(startauth->pwdtype,"pwdno")){
             changetoscreen(E_SCREEN_WORKTYPE_SET);
          }
       }
    }
    else if(isequal(startauth->flag,"fail"))
    {
       startauthfail("启 动 失 败 ！",startauth->failreason);
    }
}

void mem_pwdauthack(char *gunno,struct t_pwdauthack *pwdauthack)
{

     if (isequal(pwdauthack->type,"manauth"))
     {
        if(isequal(pwdauthack->flag,"succ"))//认证成功
        {
          changetoscreen(E_SCREEN_MANAGE_SELECT);
        }
        else if(isequal(pwdauthack->flag,"fail"))//认证失败
        {
          mem_settextvalue( MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_TEXT_POINTMSG),"密码错误,请重新输入");
        }
   }
   else if(isequal(pwdauthack->type,"cardauth"))
   {
       if(atoi(gunno) != gtcscreen.gunselect)
       {
          return ;
       }
       if(isequal(pwdauthack->flag,"succ"))//认证成功
       {
         changetoscreen(E_SCREEN_WORKTYPE_SET);
       }
       else if(isequal(pwdauthack->flag,"fail"))//认证失败
       {
           mem_settextvalue( MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_POINTMSG),"密码错误,请重新输入");
       }
   }
}

uint8 mem_getfilecheck(struct t_filecheck *filecheck)
{
   struct t_screendeal * deal = MEM_GETDEAL(gtcscreen.screennow);
   if(deal && deal->_screengetfilecheck)
   {
      return   deal->_screengetfilecheck(filecheck);
   }
   return 0;
}
void mem_filecheckack(struct t_filecheckack *filecheck)
{
    struct t_screendeal * deal = MEM_GETDEAL(gtcscreen.screennow);
    if (deal && deal->_screenfilecheckack)
    {
      deal->_screenfilecheckack(filecheck);
    }
}
uint8 mem_getfilechange(struct t_filechange *filechange)
{
    struct t_screendeal * deal = MEM_GETDEAL(gtcscreen.screennow);
    if (deal && deal->_screenfilechange)
    {
       return deal->_screenfilechange(filechange);
    }
    return 0;
}
void mem_poll(void)
{
    driver_poll();
    struct t_screendeal * deal = MEM_GETDEAL(gtcscreen.screennow);
    if(deal && deal->_pollscreen)
    {
        deal->_pollscreen();
    }
}
void mem_setrtc(const char *time)
{
    char year[5] = {0};
    char month[3] = {0};
    char date[3] = {0};
    char hour[3] = {0};
    char minute[3] = {0};
    char second[3] = {0};
    char weekend[3] = {0};

    memcpy(year,time,sizeof(year)-1);
    memcpy(month,time+4,sizeof(month)-1);
    memcpy(date,time+6,sizeof(date)-1);
    memcpy(hour,time+8,sizeof(hour)-1);
    memcpy(minute,time+10,sizeof(minute)-1);
    memcpy(second,time+12,sizeof(second)-1);
    memcpy(weekend,time+14,sizeof(weekend)-1);

    struct t_rtc rtc;
    rtc.year = atoi(year)-2000;
    rtc.month = atoi(month);
    rtc.date = atoi(date);
    rtc.hour = atoi(hour);
    rtc.minute = atoi(minute);
    rtc.second = atoi(second);
    rtc.weekend = atoi(weekend);

    setrtc(rtc.year,rtc.month,rtc.date,rtc.hour,rtc.minute,rtc.second,rtc.weekend);
}
uint8 mem_getrtc(char *time)
{
  if(!gtcscreen.screendata.time.timesendstate)//没有发送读取rtc的
  {
      readrtc();
      gtcscreen.screendata.time.timesendstate = 1;
      return 0;
  }
  if(!gtcscreen.screendata.time.timestate)//数据没有回来
  {
      return 0;
  }
  //数据回来了
  struct t_rtc rtc;
  rtc.year = gtcscreen.screendata.time.year;
  rtc.month =gtcscreen.screendata.time.month;
  rtc.date = gtcscreen.screendata.time.date;
  rtc.hour = gtcscreen.screendata.time.hour;
  rtc.minute = gtcscreen.screendata.time.minute;
  rtc.second = gtcscreen.screendata.time.second;
  rtc.weekend = gtcscreen.screendata.time.weekend;

  memset((uint8 *)&gtcscreen.screendata.time,0,sizeof(struct t_rtc));
  sprintf(time,"%02d%02d%02d%02d%02d%02d%02d",rtc.year,rtc.month,rtc.date,rtc.hour,rtc.minute,rtc.second,rtc.weekend);
  return 1;
}

uint8 mem_getyk(struct t_prodevyk *yk)
{
  struct t_screendeal *deal = MEM_GETDEAL(gtcscreen.screennow);
  if(deal && deal->_getyaokong)
  {
    return deal->_getyaokong(yk);
  }
  return 0;
}
uint8 mem_getpwdauth(struct t_pwdauth *auth)
{
  struct t_screendeal *deal = MEM_GETDEAL(gtcscreen.screennow);
  if(deal && deal->_getpwdauth)
  {
    return deal->_getpwdauth(auth);
  }
  return 0;
}
uint8 mem_getguiver(char *ver)
{
   sprintf(ver,"%s",GUI_VER);
   return 1;
}

void mem_initgui(const struct t_proinitmsg *msg)
{
	 
    sprintf(gtcscreen.screendata.companydesc.name,"深圳市广天川新能源有限公司");
    gtcscreen.screendata.companydesc.icon = 0;

    memcpy((uint8 *)&gtcscreen.screendata.proinitmsg,(uint8 *)msg,sizeof(struct t_proinitmsg));

    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_BUTTON_STOP),0);
    mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_DC,E_BUTTON_STOP),0);

    hidecontrolsingle();
    resetscreen();
}

static void mem_NOTIFYHandShake(void)//握手通知
{
	
}
static void mem_NotifyScreen(uint16 screen_id)//画面切换通知
{
	
}
static void mem_NotifyButton(uint16 screen_id, uint16 control_id, uint8 state)//按钮控件通知
{
    if(screen_id != gtcscreen.screennow)
    {
        return ;
    }
    struct t_contrilmsg *pbutton = MEM_GETCONTROLID(screen_id,control_id);
    button_trigger(pbutton,state);
}
static void dealsysytypevalue(uint16 screen_id, uint16 control_id, char *str)
{
   uint32 flag = gtcscreen._sysvalueset.flag;
   if(0 == flag)//为0时先记录被改的配置文件的位置
   {
     if(control_id <= E_TEXT_MANVALUE+MANAGEMAX ||
         control_id >= E_TEXT_MANVALUE+1 )
     {
         uint32 pos = control_id - E_TEXT_MANVALUE -1;
         *(gtcscreen._sysvalueset.driver+pos) = 1;
    }
   }
   else if(2 == flag)//为1时记录值
   {
       if(control_id <= E_TEXT_MANTYPE+MANAGEMAX &&
          control_id >= E_TEXT_MANTYPE+1 )
	   {
           sprintf(gtcscreen._sysvalueset.type,"%s",str);
	   }
       else if(control_id <= E_TEXT_MANVALUE+MANAGEMAX &&
          control_id >= E_TEXT_MANVALUE+1 )
	   {
           sprintf(gtcscreen._sysvalueset.value,"%s",str);
	   }
   }
}
static void mem_NotifyText(uint16 screen_id, uint16 control_id, uint8 *str)//文本通知信息
{   
    if(screen_id != gtcscreen.screennow)
    {
        return ;
    }
    if(E_SCREEN_TYPEVALUE_SET == gtcscreen.screennow)
    {
        dealsysytypevalue(screen_id,control_id,(char *)str);
    }else
    {
       struct t_contrilmsg *ptext = MEM_GETCONTROLID(screen_id,control_id);
       driver_settextvalue(ptext,(char *)str);
    }
}
static void mem_NotifyProgress(uint16 screen_id, uint16 control_id, uint32 value)//进度条通知
{
	
}
static void mem_NotifySlider(uint16 screen_id,uint16 control_id,uint16 value)//滑块条控件
{

}
static void mem_NotifyMeter(uint16 screen_id,uint16 control_id,uint16 value)//仪表盘控件
{
	
}
static void mem_NotifyMenu(uint16 screen_id, uint16 control_id, uint8 item, uint8 state)//菜单控件
{
	
}
static void mem_NotifySelector(uint16 screen_id, uint16 control_id, uint8  item)//选择控件
{
	
}
static void mem_NotifyTimer(uint16 screen_id, uint16 control_id)//倒计时控件
{
    if(screen_id != gtcscreen.screennow)
    {
        return ;
    }
    struct t_contrilmsg *pcnt = MEM_GETCONTROLID(screen_id,control_id);
    rtctimeout(pcnt);
}

static unsigned char bcd_to_hex(unsigned char data)
{
    unsigned char temp;

    temp = ((data>>4)*10 + (data&0x0f));
    return temp;
}
/*
static unsigned char hex_to_bcd(unsigned char data)
{
    unsigned char temp;

    temp = (((data/10)<<4) + (data%10));
    return temp;
}
*/
static void mem_NotifyReadRTC(uint8 year,uint8 month,uint8 week,uint8 day,uint8 hour,uint8 minute,uint8 second)//rtc时间读取通知
{
     gtcscreen.screendata.time.year = bcd_to_hex(year);
     gtcscreen.screendata.time.month = bcd_to_hex(month);
     gtcscreen.screendata.time.date = bcd_to_hex(day);
     gtcscreen.screendata.time.hour = bcd_to_hex(hour);
     gtcscreen.screendata.time.minute = bcd_to_hex(minute);
     gtcscreen.screendata.time.second = bcd_to_hex(second);
     gtcscreen.screendata.time.weekend = bcd_to_hex(week);

     gtcscreen.screendata.time.timestate = 1;
}

void mem_init(void)
{
    memset((uint8 *)&gtcscreen,0,sizeof(gtcscreen));

    gtcscreen._driver._NOTIFYHandShak  = mem_NOTIFYHandShake;
    gtcscreen._driver._NotifyScreen = mem_NotifyScreen;
    gtcscreen._driver._NotifyButton = mem_NotifyButton;
    gtcscreen._driver._NotifyText = mem_NotifyText;
    gtcscreen._driver._NotifyProgress = mem_NotifyProgress;
    gtcscreen._driver._NotifySlider = mem_NotifySlider;
    gtcscreen._driver._NotifyMeter = mem_NotifyMeter;
    gtcscreen._driver._NotifyMenu = mem_NotifyMenu;
    gtcscreen._driver._NotifySelector = mem_NotifySelector;
    gtcscreen._driver._NotifyTimer = mem_NotifyTimer;
    gtcscreen._driver._NotifyReadRTC = mem_NotifyReadRTC;

    driver_init(&gtcscreen._driver);

    gtcscreen.logo = E_ICON_LOGO;
    gtcscreen.companyname = E_TEXT_COMPANYNAME;
    gtcscreen.netlogo = E_ICON_NET;
    gtcscreen.devnum = E_TEXT_DEVNUM;
    gtcscreen.rtc = 0;
//主界面单枪
    struct mainwaitgun *pmainwaitgun = &gtcscreen._mainwaitgun;
    pmainwaitgun->screendeal._initscreen = reloadingmainwaitgun;
    pmainwaitgun->screendeal._pollscreen = pollmainwaitgun;

//主界面双枪
    struct maindouble *pmaindouble = &gtcscreen._maindouble;
    pmaindouble->screendeal._initscreen = reloadingmaindouble;
    pmaindouble->screendeal._pollscreen = pollmaindouble;
//选择启动方式界面
    struct wayselect *pwayselect = &gtcscreen._wayselect;
    pwayselect->screendeal._initscreen = reloadingwayselect;
    pwayselect->screendeal._pollscreen = pollwayselect;
//等待输入密码界面
    struct waitpwd *pwaitpwd = &gtcscreen._waitpwd;
    pwaitpwd->screendeal._initscreen = reloadingwaitpwd;
    pwaitpwd->screendeal._pollscreen = pollwaitpwd;
    pwaitpwd->screendeal._getpwdauth = waitpwd_getpwdauth;
//设置充电类型界面
    struct worktypeset *pworktypeset = &gtcscreen._worktypeset;
    pworktypeset->screendeal._initscreen = reloadingworktypeset;
    pworktypeset->screendeal._pollscreen = pollworktypeset;
    pworktypeset->screendeal._getyaokong = worktypeset_screengetyk;
//设置充电参数界面
    struct workvalueset *pworkvalueset = &gtcscreen._workvalueset;
    pworkvalueset->screendeal._initscreen = reloadingworkvalueset;
    pworkvalueset->screendeal._pollscreen = pollworkvalueset;
    pworkvalueset->screendeal._getyaokong = workvalueset_screengetyk;
//等待枪连接界面
    struct waitgun *pwaitgun = &gtcscreen._waitgun;
    pwaitgun->screendeal._initscreen = reloadingwaitgun;
    pwaitgun->screendeal._pollscreen = pollwaitgun;
//充电中界面(交流)
    struct chargingac *pchargingac = &gtcscreen._chargingac;
    pchargingac->screendeal._initscreen = reloadingchargeac;
    pchargingac->screendeal._pollscreen = pollchargingac;
    pchargingac->screendeal._dealscreenupdateyc = chargingac_updateyc;
//充电中界面(直流)
    struct chargingdc *pchargingdc = &gtcscreen._chargingdc;
    pchargingdc->screendeal._initscreen = reloadingchargedc;
    pchargingdc->screendeal._pollscreen = pollchargingdc;
    pchargingdc->screendeal._dealscreenupdateyc = chargingdc_updateyc;
//充电中界面_费用信息
    struct  charingcost *pchargingcost = &gtcscreen._charingcost;
    pchargingcost->screendeal._initscreen = reloadingchargecost;
    pchargingcost->screendeal._pollscreen = pollchargingcost;
    pchargingcost->screendeal._dealscreenupdateyc = chargingcost_updateyc;
//结算界面
    struct  settle *psettle = &gtcscreen._settle;
    psettle->screendeal._initscreen = reloadingsettle;
    psettle->screendeal._pollscreen = pollsettle;
    psettle->screendeal._dealscreenupdateyc = settle_updateyc;
//告警界面
    struct alarm *palarm = &gtcscreen._alarm;
    palarm->screendeal._initscreen = reloadingalarm;
    palarm->screendeal._pollscreen = pollalarm;
    palarm->screendeal._dealscreenupdateyc = alarm_updateyc;
//等待输入密码界面(管理界面)
    struct managewaitpwd *pmanagewaitpwd = &gtcscreen._managewaitpwd;
    pmanagewaitpwd->screendeal._initscreen = reloadingmanagewaitpwd;
    pmanagewaitpwd->screendeal._pollscreen = pollmanagewaitpwd;
    pmanagewaitpwd->screendeal._getpwdauth = manwaitpwd_getpwdauth;
//管理选择界面
    struct manageselect *pmanageselect = &gtcscreen._manageselect;
    pmanageselect->screendeal._initscreen = reloadingselectmanage;
    pmanageselect->screendeal._pollscreen = pollmanageselect;
    pmanageselect->screendeal._getyaokong = manselect_screengetyk;
//系统参数配置界面
    struct sysvalueset *psysvalueset = &gtcscreen._sysvalueset;
    psysvalueset->screendeal._initscreen = reloadingtypevalueset;
    psysvalueset->screendeal._pollscreen = pollmanagesysset;
    psysvalueset->screendeal._screengetfilecheck = sysvaluesetgetfilecheck;
    psysvalueset->screendeal._screenfilecheckack = sysvaluesetfilecheckack;
    psysvalueset->screendeal._screenfilechange = sysvaluesetfilechange;
//记录查看界面
    struct recordcheck *precordcheck = &gtcscreen._recordcheck;
    precordcheck->screendeal._initscreen = reloadingrecordcheck;
    precordcheck->screendeal._pollscreen = pollrecordcheck;
    precordcheck->screendeal._screengetfilecheck = recordgetfilecheck;
		precordcheck->screendeal._screenfilecheckack = recordgetfilecheckack;
//调试界面		
    struct debug *pdebug = &gtcscreen._debug;
    pdebug->screendeal._initscreen = reloadingdebug;
    pdebug->screendeal._pollscreen = polldebug; 
//询问界面
    struct communicate *pcommunicate = &gtcscreen._communicate;
    pcommunicate->screendeal._initscreen = reloadingcommunicate;
    pcommunicate->screendeal._pollscreen = pollcommunicate;
    pcommunicate->screendeal._getyaokong = communicate_screengetyk;
}
